<form class="layui-form layui-form-pane" method="post" action="" enctype="multipart/form-data" >
    <style>
        #demo2 img {
            width: 100px;
            margin-left: 20px;
        }
    </style>
    @csrf

    <input type="hidden" name="id" value="{{$id}}">
    <div class="layui-form-item" id="title" style="display:none">
        <label class="layui-form-label">标题</label>
        <div class="layui-input-inline" style="width:30%;">
            <input type="type" name="title" value='{{$list['title']}}' placeholder='请输入标题' autocomplete="off" class="layui-input" >
        </div>
        <div class="layui-form-mid layui-word-aux"></div>
    </div>

    <div class="layui-form-item" id="editor">
        <label class="layui-form-label">内容:</label>
        <div class="layui-input-block">
            <textarea id="demo" style="display: none;" name="content">{{$list['content']}}</textarea>
        </div>
    </div>
    <div class="layui-form-item" >
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>
    <input type="hidden" name="page" value="{{$request->page}}">
    <input type="hidden" name="keywords" value="{{$request->keywords}}">
    <input type="hidden" name="label" value="{{$request->label}}">
    <input type="hidden" name="type" value="{{$request->type}}">
    <input type="hidden" name="brand" value="{{$request->brand}}">
    <input type="hidden" name="state" value="{{$request->state}}">
    <input type="hidden" name="sell" value="{{$request->sell}}">
    <input type="hidden" name="month" value="{{$request->month}}">
    <input type="hidden" name="title" value="{{$request->title}}">
    <input type="hidden" name="sort" value="{{$request->sort}}">
</form>
<script>
    //Demo
    layui.use('form', function(){
        var form = layui.form;
        form.render();

        layui.use(['layedit','form'],
            function() {
                var layedit = layui.layedit;
                layedit.set({
                    uploadImage: {
                        url: '/admin/source_up',
                        type: 'post'
                    }
                });
                var index = layedit.build('demo'); //建立编辑器
                var form = layui.form;
                var layedit = layui.layedit;

                //监听提交
                form.on('submit(formDemo)', function(data){
                    var page = $("input[name=page]").val();
                    var keywords = $("input[name=keywords]").val();
                    var label = $("input[name=label]").val();
                    var type = $("input[name=type]").val();
                    var brand = $("input[name=brand]").val();
                    var state = $("input[name=state]").val();
                    var sell = $("input[name=sell]").val();
                    var month = $("input[name=month]").val();
                    var title = $("input[name=title]").val();
                    var sort = $("input[name=sort]").val();
                    var aa = layedit.getContent(index);
                    data.field.contents = aa;
                    layer.confirm('确认执行此操作？', {icon: 3, title:'提示'}, function(index){
                        ajax("{{url('admin/shop/source_update')}}",data.field,function(data){
                            layer.close();
                            layer.closeAll();
                            layer.msg(data.msg);
                            if(data.code == 1){
                                location.href = '/admin/shop/source?id='+ {{$list['gid']}}+'&types='+data['data']+'&page='+page+'&keywords='+keywords+'&label='+label+'&type='+types+'&brand='+brand+'&state='+state+'&sell='+sell+'&month='+month+'&title='+title+'&sort='+sort;
                            }
                        });
                    });
                    return false;
                });
            });

        });
</script>
